/*
 * SetschenowModel.cpp
 *
 *  Created on: 1 Aug 2011
 *      Author: Allan
 */

#include "SetschenowModel.h"

// GeoReact includes
#include "../../ElectrolyteSolution.h"
#include "../../Numerics/LinearInterpolator.h"

const double SetschenowActivityCoefficient(const ElectrolyteSolution& sol, double T, double P, const VectorXd& n, const LinearInterpolator& b)
{
	// The mole-fraction of the water species to convert the activity coefficient from mole-fraction scale to molality scale
	const double xw = n[sol.GetWaterIndex()] / n.sum();
	
	// The effective ionic strength of the solution
	const double I = sol.EffectiveIonicStrength(n);
	
	// Return the activity coefficient of the neutral species in a molality scale
	return xw * std::pow(10.0, b(T) * I);
}
